package com.im.service.folderManage.smo;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.im.MDA;
import com.im.service.dto.DocInfo;
import com.im.service.dto.FileBorrow;
import com.im.service.dto.FileUpload;
import com.im.service.dto.ProjectStage;
import com.im.service.dto.Staff;
import com.im.service.dto.StageNode;
import com.im.service.folderManage.dao.IFolderManageOperDAO;
import com.im.service.folderManage.dao.IFolderManageQueryDAO;
import com.im.service.projectInfo.dao.IImplementProjOperDAO;
import com.im.service.projectInfo.dao.IImplementProjQueryDAO;
import com.im.util.JsonUtil;
import com.im.util.ReturnsUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Service
public class IFolderManageOperSMOImpl implements IFolderManageOperSMO {
	@Autowired
	private IFolderManageOperDAO folderManageOperDAO;
	@Autowired
	private IImplementProjOperDAO implementProjOperDAO;
	@Autowired
	private IImplementProjQueryDAO implementProjQueryDAO;
	@Autowired
	private IFolderManageQueryDAO folderManageQueryDAO;
	
	@Override
	public String insertDocInfo(String inJson) {
		JSONObject param = JSONObject.fromObject(inJson);
		String projStageId = JsonUtil.obtainValueFromJsonObject(inJson, "projStageId");
		String fileName = JsonUtil.obtainValueFromJsonObject(inJson, "fileName");
		String endDt = JsonUtil.obtainValueFromJsonObject(inJson, "endDt");
		String participant = JsonUtil.obtainValueFromJsonObject(inJson, "participant");
		String broker = JsonUtil.obtainValueFromJsonObject(inJson, "broker");
		String description = JsonUtil.obtainValueFromJsonObject(inJson, "description");
		String modifier = JsonUtil.obtainValueFromJsonObject(inJson, "staffId");
		String fileAttr = JsonUtil.obtainValueFromJsonObject(inJson, "fileAttr");
		String fileType = JsonUtil.obtainValueFromJsonObject(inJson, "fileType");
		String uploadId = "";
		String uploadType = "";

		DocInfo doc = new DocInfo();
		String docInfoId = UUID.randomUUID().toString();
		doc.setDocInfoId(docInfoId);
		doc.setFileName(fileName);
		doc.setDocObjId(projStageId);
		doc.setDocSourceType("10");
		doc.setEndDt(endDt);
		doc.setParticipant(participant);
		doc.setStatusCd(10);
		doc.setBroker(broker);
		doc.setDescription(description);
		doc.setModifier(modifier);
		folderManageOperDAO.insertDocInfo(doc);
		if (param.containsKey("fileList")) {
			JSONArray fileListArray = param.getJSONArray("fileList");
			if (fileListArray != null) {
				List<FileUpload> fileUploads = new ArrayList<FileUpload>();
				for (Object fileUpload : fileListArray) {
					JSONObject fileUploadJson = JSONObject.fromObject(fileUpload);
					FileUpload fileUploadInfo = new FileUpload();
					uploadId = UUID.randomUUID().toString();
					uploadType = (String) MDA.FILE_UPLOAD_TYPE.get(fileUploadJson.getString("attachSuffix").toLowerCase());
					fileUploadInfo.setUploadId(uploadId);
					fileUploadInfo.setUploadName(fileUploadJson.getString("attachFullName"));
					fileUploadInfo.setUploadObjType("90");
					fileUploadInfo.setUploadObjId(docInfoId);
					fileUploadInfo.setUploadType(uploadType);
					fileUploadInfo.setFileSuffix(fileUploadJson.getString("attachSuffix"));
					fileUploadInfo.setFileAttr(fileAttr);
					fileUploadInfo.setFileType(fileType);
					fileUploadInfo.setUploadSize(fileUploadJson.getLong("attachSize"));
					fileUploadInfo.setFilePath(fileUploadJson.getString("attachPath"));
					fileUploadInfo.setUploadDate(fileUploadJson.getString("uploadDt"));
					fileUploads.add(fileUploadInfo);
				}
				folderManageOperDAO.insertFileUploadInfos(fileUploads);
			}
		}
		//
		//
		// String uploadName = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadName");
		// String fileSuffix = JsonUtil.obtainValueFromJsonObject(inJson,
		// "fileSuffix");
		// String uploadSize = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadSize");
		// String filePath = JsonUtil.obtainValueFromJsonObject(inJson,
		// "filePath");
		// String uploadDate = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadDt");
		// String uploadDescription = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadDescription");
		//
		// if (!"".equals(uploadName)) {
		// FileUpload fileUploadInfo = new FileUpload();
		// if (!"".equals(fileSuffix)) {
		// uploadType = (int)
		// MDA.FILE_UPLOAD_TYPE.get(fileSuffix.toLowerCase());
		// }
		// uploadId = UUID.randomUUID().toString();
		// fileUploadInfo.setUploadId(uploadId);
		// fileUploadInfo.setUploadName(uploadName);
		// fileUploadInfo.setUploadObjType(50);
		// fileUploadInfo.setUploadObjId(uploadObjId);
		// fileUploadInfo.setUploadType(uploadType);
		// fileUploadInfo.setFileSuffix(fileSuffix);
		// fileUploadInfo.setFileAttr(fileAttr);
		// fileUploadInfo.setFileType(fileType);
		// fileUploadInfo.setUploadSize(Long.valueOf(uploadSize));
		// fileUploadInfo.setFilePath(filePath);
		// fileUploadInfo.setUploadDate(uploadDate);
		// fileUploadInfo.setDescription(uploadDescription);
		// folderManageOperDAO.insertFileUploadInfo(fileUploadInfo);
		// }
		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public String updateDocInfo(String inJson) {
		JSONObject param = JSONObject.fromObject(inJson);
		String docInfoId = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoId");
		String fileName = JsonUtil.obtainValueFromJsonObject(inJson, "fileName");
		String endDt = JsonUtil.obtainValueFromJsonObject(inJson, "endDt");
		String participant = JsonUtil.obtainValueFromJsonObject(inJson, "participant");
		String broker = JsonUtil.obtainValueFromJsonObject(inJson, "broker");
		String description = JsonUtil.obtainValueFromJsonObject(inJson, "description");
		String modifier = JsonUtil.obtainValueFromJsonObject(inJson, "staffId");
		String fileAttr = JsonUtil.obtainValueFromJsonObject(inJson, "fileAttr");
		String fileType = JsonUtil.obtainValueFromJsonObject(inJson, "fileType");

		String uploadId = "";
		String uploadType = "";

		DocInfo doc = new DocInfo();
		doc.setDocInfoId(docInfoId);
		doc.setFileName(fileName);
		// doc.setDocObjId(docObjId);
		doc.setEndDt(endDt);
		doc.setParticipant(participant);
		doc.setBroker(broker);
		doc.setDescription(description);
		doc.setModifier(modifier);
		folderManageOperDAO.updateDocInfo(doc);
		if (param.containsKey("fileList")) {
			JSONArray fileListArray = param.getJSONArray("fileList");
			if (fileListArray != null) {
				List<FileUpload> fileUploads = new ArrayList<FileUpload>();
				for (Object fileUpload : fileListArray) {
					JSONObject fileUploadJson = JSONObject.fromObject(fileUpload);
					FileUpload fileUploadInfo = new FileUpload();
					uploadId = UUID.randomUUID().toString();
					uploadType = (String) MDA.FILE_UPLOAD_TYPE.get(fileUploadJson.getString("attachSuffix").toLowerCase());
					fileUploadInfo.setUploadId(uploadId);
					fileUploadInfo.setUploadName(fileUploadJson.getString("attachFullName"));
					fileUploadInfo.setUploadObjType("90");
					fileUploadInfo.setUploadObjId(docInfoId);
					fileUploadInfo.setUploadType(uploadType);
					fileUploadInfo.setFileSuffix(fileUploadJson.getString("attachSuffix"));
					fileUploadInfo.setFileAttr(fileAttr);
					fileUploadInfo.setFileType(fileType);
					fileUploadInfo.setUploadSize(fileUploadJson.getLong("attachSize"));
					fileUploadInfo.setFilePath(fileUploadJson.getString("attachPath"));
					fileUploadInfo.setUploadDate(fileUploadJson.getString("uploadDt"));
					fileUploads.add(fileUploadInfo);
				}
				folderManageOperDAO.insertFileUploadInfos(fileUploads);
			}
		}
		if(param.containsKey("delFiles")){
			JSONArray delFilesArray = param.getJSONArray("delFiles");
			if (delFilesArray != null && delFilesArray.size() > 0) {
				List<String> delFileUploadIds = new ArrayList<String>();
				for (Object fileUpload : delFilesArray) {
					JSONObject delFileUploadJson = JSONObject.fromObject(fileUpload);
					String deUuploadId = delFileUploadJson.getString("uploadId");
					if(deUuploadId != null && !"".equals(deUuploadId)){
						delFileUploadIds.add(deUuploadId);
					}
				}
				if(delFileUploadIds.size() > 0){
					Map<String, Object> docUploadMap = new HashMap<String, Object>();
					docUploadMap.put("delFileUploadIds", delFileUploadIds);
					folderManageOperDAO.delFileUploads(docUploadMap);
				}
			}
		}
		// uploadId = JsonUtil.obtainValueFromJsonObject(inJson, "uploadId");
		// String uploadName = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadName");
		// String fileSuffix = JsonUtil.obtainValueFromJsonObject(inJson,
		// "fileSuffix");

		// String uploadSize = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadSize");
		// String filePath = JsonUtil.obtainValueFromJsonObject(inJson,
		// "filePath");
		// String uploadDate = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadDt");
		// String uploadDescription = JsonUtil.obtainValueFromJsonObject(inJson,
		// "uploadDescription");

		// if (!"".equals(uploadId)) {
		// FileUpload fileUploadInfo = new FileUpload();
		// fileUploadInfo.setUploadId(uploadId);
		// fileUploadInfo.setUploadName(uploadName);
		// // fileUploadInfo.setUploadObjType(50);
		// if (!"".equals(fileSuffix)) {
		// uploadType = (int)
		// MDA.FILE_UPLOAD_TYPE.get(fileSuffix.toLowerCase());
		// }
		// fileUploadInfo.setUploadType(uploadType);
		// fileUploadInfo.setFileSuffix(fileSuffix);
		// fileUploadInfo.setFileAttr(fileAttr);
		// fileUploadInfo.setFileType(fileType);
		// fileUploadInfo.setUploadSize(Long.valueOf(uploadSize));
		// fileUploadInfo.setFilePath(filePath);
		// fileUploadInfo.setUploadDate(uploadDate);
		// fileUploadInfo.setDescription(uploadDescription);
		// folderManageOperDAO.updateFileUploadInfo(fileUploadInfo);
		// } else if ("".equals(uploadId) && !"".equals(uploadName)) {
		// FileUpload fileUploadInfo = new FileUpload();
		// if (!"".equals(fileSuffix)) {
		// uploadType = (int)
		// MDA.FILE_UPLOAD_TYPE.get(fileSuffix.toLowerCase());
		// }
		// uploadId = UUID.randomUUID().toString();
		// fileUploadInfo.setUploadId(uploadId);
		// fileUploadInfo.setUploadName(uploadName);
		// fileUploadInfo.setUploadObjType(50);
		// fileUploadInfo.setUploadObjId(docInfoId);
		// fileUploadInfo.setUploadType(uploadType);
		// fileUploadInfo.setFileSuffix(fileSuffix);
		// fileUploadInfo.setFileAttr(fileAttr);
		// fileUploadInfo.setFileType(fileType);
		// fileUploadInfo.setUploadSize(Long.valueOf(uploadSize));
		// fileUploadInfo.setFilePath(filePath);
		// fileUploadInfo.setUploadDate(uploadDate);
		// fileUploadInfo.setDescription(uploadDescription);
		// folderManageOperDAO.insertFileUploadInfo(fileUploadInfo);
		// }

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public void insertFileUploadInfo(FileUpload fileUpload) {
		folderManageOperDAO.insertFileUploadInfo(fileUpload);
	}

	@Override
	public void updateFileUploadInfo(FileUpload fileUpload) {
		folderManageOperDAO.updateFileUploadInfo(fileUpload);
	}

	@Override
	public String insertBatchFileBorrowInfo(String inJson) {
		String docInfoIdList = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoIds");
		String borrowType = JsonUtil.obtainValueFromJsonObject(inJson, "borrowType");
		String outBroker = JsonUtil.obtainValueFromJsonObject(inJson, "outBroker");
		String borrower = JsonUtil.obtainValueFromJsonObject(inJson, "borrowerId");
		String description = JsonUtil.obtainValueFromJsonObject(inJson, "description");

		List<FileBorrow> fBorrows = new ArrayList<FileBorrow>();
		String[] docInfoIds = docInfoIdList.split(",");
		List<String> newList = new ArrayList<String>();
		for (String docInfoId : docInfoIds) {
			Map<String, Object> docUploadMap = new HashMap<String, Object>();
			docUploadMap.put("uploadObjId", docInfoId);
			List<FileUpload> fileUploadList = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
			if(fileUploadList.size() > 0){
				FileUpload fileUploadInfo = fileUploadList.get(0);
				if("20".equals(fileUploadInfo.getFileType())){
					String fileBorrowId = UUID.randomUUID().toString();
					FileBorrow fileBorrow = new FileBorrow();
					fileBorrow.setFileBorrowId(fileBorrowId);
					fileBorrow.setDocInfoId(docInfoId);
					fileBorrow.setBorrowType(borrowType);
					fileBorrow.setOutBroker(outBroker);
					fileBorrow.setBorrower(borrower);
					fileBorrow.setStatusCd(10);
					fileBorrow.setDescription(description);
					fBorrows.add(fileBorrow);
					newList.add(docInfoId);
				}
			}else{
				String fileBorrowId = UUID.randomUUID().toString();
				FileBorrow fileBorrow = new FileBorrow();
				fileBorrow.setFileBorrowId(fileBorrowId);
				fileBorrow.setDocInfoId(docInfoId);
				fileBorrow.setBorrowType(borrowType);
				fileBorrow.setOutBroker(outBroker);
				fileBorrow.setBorrower(borrower);
				fileBorrow.setStatusCd(10);
				fileBorrow.setDescription(description);
				fBorrows.add(fileBorrow);
				newList.add(docInfoId);
			}
		}
		if(fBorrows.size() > 0){
			folderManageOperDAO.insertBatchFileBorrowInfo(fBorrows);

			Map<String, Object> docMap = new HashMap<String, Object>();
			docMap.put("statusCd", 20);
			docMap.put("docInfoIds", newList);
			folderManageOperDAO.updateDocInfoStatusCdByDocInfoIds(docMap);
		}

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public String updateFileBorrowInfo(String inJson) {
		String docInfoId = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoId");
		String fileBorrowId = JsonUtil.obtainValueFromJsonObject(inJson, "fileBorrowId");
		String returnBroker = JsonUtil.obtainValueFromJsonObject(inJson, "returnBroker");
		String borrower = JsonUtil.obtainValueFromJsonObject(inJson, "borrower");
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(currentTime);
		FileBorrow fileBorrow = new FileBorrow();
		fileBorrow.setFileBorrowId(fileBorrowId);
		fileBorrow.setReturnBroker(returnBroker);
		fileBorrow.setReturnDt(dateString);
		fileBorrow.setBorrower(borrower);
		folderManageOperDAO.updateFileBorrowInfo(fileBorrow);

		Map<String, Object> docMap = new HashMap<String, Object>();
		docMap.put("statusCd", 10);
		docMap.put("docInfoId", docInfoId);

		folderManageOperDAO.updateDocInfoStatusCdByDocInfoId(docMap);

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public void insertChildNodeInfo(StageNode stageNode) {
		folderManageOperDAO.insertChildNodeInfo(stageNode);
	}

	@Override
	public void updateDocInfoStatusCdByDocInfoIds(Map<String, Object> param) {
		folderManageOperDAO.updateDocInfoStatusCdByDocInfoIds(param);
	}

	@Override
	public void updateFileBorrowInfoByDocInfoId(Map<String, Object> param) {
		folderManageOperDAO.updateFileBorrowInfoByDocInfoId(param);
	}

	@Override
	public String insertFileBorrowInfo(String inJson) {
		String docInfoId = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoId");
		String borrowType = JsonUtil.obtainValueFromJsonObject(inJson, "borrowType");
		String outBroker = JsonUtil.obtainValueFromJsonObject(inJson, "outBroker");
		String borrower = JsonUtil.obtainValueFromJsonObject(inJson, "borrowerId");
		String description = JsonUtil.obtainValueFromJsonObject(inJson, "description");

		String fileBorrowId = UUID.randomUUID().toString();
		FileBorrow fileBorrow = new FileBorrow();
		fileBorrow.setFileBorrowId(fileBorrowId);
		fileBorrow.setDocInfoId(docInfoId);
		fileBorrow.setBorrowType(borrowType);
		fileBorrow.setOutBroker(outBroker);
		fileBorrow.setBorrower(borrower);
		fileBorrow.setStatusCd(10);
		fileBorrow.setDescription(description);
		folderManageOperDAO.insertFileBorrowInfo(fileBorrow);

		DocInfo docInfo = new DocInfo();
		docInfo.setStatusCd(20);
		docInfo.setDocInfoId(docInfoId);
		folderManageOperDAO.updateDocInfo(docInfo);

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public void updateDocInfoStatusCdByDocInfoId(Map<String, Object> param) {
		folderManageOperDAO.updateDocInfoStatusCdByDocInfoId(param);
	}

	@Override
	public String updateBatchFileBorrowInfo(String inJson) {
		String docInfoIdList = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoIds");
		String fileBorrowIdList = JsonUtil.obtainValueFromJsonObject(inJson, "fileBorrowIds");
		String returnBroker = JsonUtil.obtainValueFromJsonObject(inJson, "returnBroker");
		String[] docInfoIds = docInfoIdList.split(",");
		String[] fileBorrowIds = fileBorrowIdList.split(",");
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(currentTime);
		Map<String, Object> borrowMap = new HashMap<String, Object>();
		borrowMap.put("fileBorrowIds", fileBorrowIds);
		borrowMap.put("returnBroker", returnBroker);
		borrowMap.put("returnDt", dateString);
		folderManageOperDAO.updateFileBorrowInfoByDocInfoId(borrowMap);

		Map<String, Object> docMap = new HashMap<String, Object>();
		docMap.put("statusCd", 10);
		docMap.put("docInfoIds", docInfoIds);
		folderManageOperDAO.updateDocInfoStatusCdByDocInfoIds(docMap);

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public String deleteDocInfo(String inJson) {
		String docInfoId = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoId");

		Map<String, Object> docMap = new HashMap<String, Object>();
		docMap.put("statusCd", 30);
		docMap.put("docInfoId", docInfoId);
		folderManageOperDAO.updateDocInfoStatusCdByDocInfoId(docMap);

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public String deleteDocInfos(String inJson) {
		String docInfoIdList = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoIds");
		String[] docInfoIds = docInfoIdList.split(",");

		Map<String, Object> docMap = new HashMap<String, Object>();
		docMap.put("statusCd", 30);
		docMap.put("docInfoIds", docInfoIds);
		folderManageOperDAO.updateDocInfoStatusCdByDocInfoIds(docMap);

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public String delFileUploadByUploadId(String inJson) {
		String uploadId = JsonUtil.obtainValueFromJsonObject(inJson, "uploadId");
		Map<String, Object> uploadMap = new HashMap<String, Object>();
		uploadMap.put("uploadId", uploadId);
		folderManageOperDAO.delFileUpload(uploadMap);
		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}
	
	@Override
	public String addDocInfo(String inJson) {
		JSONObject param = JSONObject.fromObject(inJson);
		String projStageId = JsonUtil.obtainValueFromJsonObject(inJson, "projStageId");
		String impleProjId = JsonUtil.obtainValueFromJsonObject(inJson, "impleProjId");
		String projStageClass = JsonUtil.obtainValueFromJsonObject(inJson, "projStageClass");
		String uploadId = "";
		String uploadType = "";

		if(projStageId == null || "".equals(projStageId)){
			ProjectStage stageInfo = new ProjectStage();
			stageInfo.setImpleProjId(impleProjId);
			stageInfo.setProjStageClass(projStageClass);
			List<ProjectStage> projStageList = implementProjQueryDAO.queryImpleProjStageListForDocInfo(stageInfo);
			if(projStageList.size() > 0){
				projStageId = projStageList.get(0).getProjStageId();
			}else{
				ProjectStage projStage = new ProjectStage();
				projStageId = UUID.randomUUID().toString();
				projStage.setProjStageId(projStageId);
				projStage.setImpleProjId(impleProjId);
				projStage.setStatusCd(20);
				projStage.setProjStageClass(projStageClass);
				projStage.setProjStageType("20");
				implementProjOperDAO.addProjStage(projStage);
			}
		}
		
		String fileName = JsonUtil.obtainValueFromJsonObject(inJson, "fileName");
		String endDt = JsonUtil.obtainValueFromJsonObject(inJson, "endDt");
		String participant = JsonUtil.obtainValueFromJsonObject(inJson, "participant");
		String broker = JsonUtil.obtainValueFromJsonObject(inJson, "broker");
		if(broker == null || "".equals(broker)){
			broker = JsonUtil.obtainValueFromJsonObject(inJson, "staffId");
		}
		String description = JsonUtil.obtainValueFromJsonObject(inJson, "description");
		String modifier = JsonUtil.obtainValueFromJsonObject(inJson, "staffId");
		String fileAttr = JsonUtil.obtainValueFromJsonObject(inJson, "fileAttr");
		String fileType = JsonUtil.obtainValueFromJsonObject(inJson, "fileType");
		
		DocInfo doc = new DocInfo();
		String docInfoId = UUID.randomUUID().toString();
		doc.setDocInfoId(docInfoId);
		doc.setFileName(fileName);
		doc.setDocObjId(projStageId);
		doc.setDocSourceType("40");
		doc.setEndDt(endDt);
		doc.setParticipant(participant);
		doc.setStatusCd(40);
		doc.setBroker(broker);
		doc.setDescription(description);
		doc.setModifier(modifier);
		folderManageOperDAO.insertDocInfo(doc);
		if (param.containsKey("fileList")) {
			JSONArray fileListArray = param.getJSONArray("fileList");
			if (fileListArray != null) {
				List<FileUpload> fileUploads = new ArrayList<FileUpload>();
				for (Object fileUpload : fileListArray) {
					JSONObject fileUploadJson = JSONObject.fromObject(fileUpload);
					FileUpload fileUploadInfo = new FileUpload();
					uploadId = UUID.randomUUID().toString();
					uploadType = (String) MDA.FILE_UPLOAD_TYPE.get(fileUploadJson.getString("attachSuffix").toLowerCase());
					fileUploadInfo.setUploadId(uploadId);
					fileUploadInfo.setUploadName(fileUploadJson.getString("attachFullName"));
					fileUploadInfo.setUploadObjType("90");
					fileUploadInfo.setUploadObjId(docInfoId);
					fileUploadInfo.setUploadType(uploadType);
					fileUploadInfo.setFileSuffix(fileUploadJson.getString("attachSuffix"));
					fileUploadInfo.setFileAttr(fileAttr);
					fileUploadInfo.setFileType(fileType);
					fileUploadInfo.setUploadSize(fileUploadJson.getLong("attachSize"));
					fileUploadInfo.setFilePath(fileUploadJson.getString("attachPath"));
					fileUploadInfo.setUploadDate(fileUploadJson.getString("uploadDt"));
					fileUploads.add(fileUploadInfo);
				}
				folderManageOperDAO.insertFileUploadInfos(fileUploads);
			}
		}
		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

	@Override
	public String updateBatchDcoInfoForAudit(String inJson) {
		String docInfoIdList = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoIds");
		String[] docInfoIds = docInfoIdList.split(",");

		Map<String, Object> docMap = new HashMap<String, Object>();
		docMap.put("statusCd", 10);
		docMap.put("docInfoIds", docInfoIds);
		folderManageOperDAO.updateDocInfoStatusCdByDocInfoIds(docMap);

		return ReturnsUtil.returnSuccess(new JSONObject()).toString();
	}

}
